<?php
	
	
	
	
	function send_mail($to, $subject = '(No subject)', $message = '')
	{ 
		require 'PHPMailer/PHPMailerAutoload.php';
		//$to = "sw3nn3@gmail.com"; //KOMMENTERA BORT DENNA  ELLER ÄNDRA
		$from_user = "Sales Makeover Admin";
		$from_email = "info@twentyfiveentertainment.com";
		
		$mail = new PHPMailer;

		$mail->isSMTP();                                      // Set mailer to use SMTP
		$mail->SMTPDebug = 2;
		$mail->Debugoutput = 'html';
		$mail->Host = 'mail.twentyfiveentertainment.com';  // Specify main and backup server
		$mail->Port = 587;  // Specify main and backup server
		$mail->SMTPAuth = true;                               // Enable SMTP authentication
		$mail->Username = 'info@twentyfiveentertainment.com';                            // SMTP username
		$mail->Password = 'intlol=25';                           // SMTP password
		$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

		$mail->From = $from_email;
		$mail->FromName = $from_user;
		//$mail->addAddress('josh@example.net', 'Josh Adams');  // Add a recipient
		$mail->addAddress($to);               // Name is optional
		//$mail->addReplyTo('info@example.com', 'Information');
		//$mail->addCC('cc@example.com');
		//$mail->addBCC('bcc@example.com');

		$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
		//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
		//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
		$mail->isHTML(true);                                  // Set email format to HTML
		$mail->CharSet = 'UTF-8';
		$mail->Subject = $subject;
		$mail->Body    = $message;
		//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

		if(!$mail->send()) {
		   //echo 'Message could not be sent.';
		   //echo 'Mailer Error: ' . $mail->ErrorInfo;
		   exit;
		}

		//echo 'Message has been sent';
	}
	
	function sendNewUserEmail($to, $newUser, $newUserCompany)
	{
		$subject = 'Sales Makeover - Ny användare';
		
		$message = '
		<html>
		<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <title>'.$subject.'</title>
		</head>
		<body>
		  En ny användare har lagts till i '.$newUserCompany.'.
		  <br/>
		  '.$newUser.'
		</body>
		</html>
		';
		
		send_mail($to, $subject, $message);
	}
	
	function sendNewManagerEmail($to, $newManager, $newManagerCompany)
	{
		$subject = 'Sales Makeover - Ny manager';
		
		$message = '
		<html>
		<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <title>'.$subject.'</title>
		</head>
		<body>
		  En ny manager har lagts till i '.$newManagerCompany.'.
		  <br/>
		  '.$newManager.'
		</body>
		</html>
		';
		
		send_mail($to, $subject, $message);
	}
	
	function sendNewCompanyEmail($to, $newCompany, $newManager)
	{
		$subject = 'Sales Makeover - Nytt företag';
		
		$message = '
		<html>
		<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <title>'.$subject.'</title>
		</head>
		<body>
		  Ett nytt företag har lagts till i systemet tillsammans med en ny manager.
		  <br/>
		  '.$newCompany.'
		  <br/>
		  '.$newManager.'
		</body>
		</html>
		';
		
		send_mail($to, $subject, $message);
	}
	
	function sendAccountInfo($to, $usersname, $key)
	{
		$hostURL = "http://twentyfiveentertainment.com/Apps/Sales%20MakeOver%20Mobile";
	
		$subject = 'Sales Makeover - Kontoinformation';
		
		$message = '
		<html>
		<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <title>'.$subject.'</title>
		</head>
		<body>
		  Hej ' . $usersname . '!<br/>
		  Din mail har blivit registerad hos Sales Makeover. Gå hit för att välja nytt lösenord och komma igång: <a href=\"'.$hostURL.'/reset.php?key=' . $key . '\">'.$hostURL.'/reset.php?key=' . $key . '</a>
		</body>
		</html>
		';
		
		send_mail($to, $subject, $message);
	}
	
	function sendNewAccountInfo($to, $usersname, $key)
	{
		$hostURL = "http://twentyfiveentertainment.com/Apps/Sales%20MakeOver%20Mobile";
	
		$subject = 'Sales Makeover - Kontoinformation';
		
		$message = '
		<html>
		<head>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <title>'.$subject.'</title>
		</head>
		<body>
		  Hej ' . $usersname . '!<br/>
		  Ditt lösenord har blivit återställt hos Sales Makeover. Gå hit för att välja nytt lösenord: <a href=\"'.$hostURL.'/reset.php?key=' . $key . '\">'.$hostURL.'/reset.php?key=' . $key . '</a>
		</body>
		</html>
		';
		
		send_mail($to, $subject, $message);
	}
	
	
?>